log using "C:\Users\mjoshi2\Google Drive\2017 Projects\FDI\CMPS\Revisions 2\2018-04-13FDI.smcl", replace

use "C:\Users\mjoshi2\Google Drive\2017 Projects\FDI\CMPS\Revisions 2\Data\2018-4-12 FDI CMPS.dta", replace
sort ccode year

//Model 1
xtabond lnfdi_inward_mil_unctad_   L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic   if year>1988 & outcome!=., vce(gmm)
vif, uncentered

//Model 2
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m if year>1988 & outcome!=.,vce(gmm)
vif, uncentered

//Model 3
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.ex_con  if year>1988 & outcome!=.,vce(gmm)
vif, uncentered

//Model 4
xtabond  lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  ln_total_dead ln_wardur cum_peace_year if year>1988 & outcome!=.,vce(gmm)
vif, uncentered

//Model 5
 xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con ln_total_dead L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. ,vce(gmm)
vif, uncentered


//Model 6
xtabond lnfdi_inward_mil_unctad_    L.inpam L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con ln_total_dead L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. ,vce(gmm)
vif, uncentered



//Table 2

//Model 7 - Introduces BITs - 
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur govonlyv413m L.ex_con L.p_durable cum_peace_year L.cum_bits L.lnpkoave_total if year>1988 & outcome!=.,vce(gmm)
vif, uncentered


//Model 8 Exchange Rate
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace L.wdi_offexrate if year>1988 & outcome!=.,vce(gmm)
vif, uncentered

//Model 9 Natural Resource
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace L.wdi_natrr if year>1988 & outcome!=.,vce(gmm)
vif, uncentered


//Model 10 Labor Force Participation
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace L.wdi_lf if year>1988 & outcome!=.,vce(gmm)
vif, uncentered


//Model 11 - All Economic Variables
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits L.wdi_offexrate L.wdi_natrr L.wdi_lf govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace if year>1988 & outcome!=.,vce(gmm)
vif, uncentered



//Model 12 uses CPA as a binary 
xtabond lnfdi_inward_mil_unctad_      L.inpam L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade  ln_wardur L.wdi_pop_mil L.cum_bits L.wdi_offexrate L.wdi_natrr L.wdi_lf govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace if year>1988 & outcome!=.,vce(gmm)
vif, uncentered



//Table 3
//Model 13
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.coldcase L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(gmm)
vif, uncentered

//Model 14
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.coldcase L.outcome_GovtVic  L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(gmm)
vif, uncentered

//Model 15
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.coldcase L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(gmm)
vif, uncentered

//Model 16
xtabond lnfdi_inward_mil_unctad_    L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.coldcase L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(gmm)
vif, uncentered



//////////////////////ROBUSTNESS TESTS//////////////////////

//A4
//Replicate Table 1 Robust SE
//Model 1
xtabond lnfdi_inward_mil_unctad_   L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic   if year>1988 & outcome!=., vce(robust)
vif, uncentered

//Model 2
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m if year>1988 & outcome!=.,vce(robust)
vif, uncentered

//Model 3
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.ex_con  if year>1988 & outcome!=.,vce(robust)
vif, uncentered

//Model 4
xtabond  lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  ln_total_dead ln_wardur cum_peace_year if year>1988 & outcome!=.,vce(robust)
vif, uncentered

//Model 5
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con ln_total_dead L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. ,vce(robust)
vif, uncentered


//Model 6
xtabond lnfdi_inward_mil_unctad_    L.inpam L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con ln_total_dead L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. ,vce(robust)
vif, uncentered



//A5 Replicate Table 2 Robust SE

//Model 7 - Introduces BITs - 
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur govonlyv413m L.ex_con L.p_durable cum_peace_year L.cum_bits L.lnpkoave_total if year>1988 & outcome!=.,vce(robust)
vif, uncentered


//Model 8 Exchange Rate
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace L.wdi_offexrate if year>1988 & outcome!=.,vce(robust)
vif, uncentered

//Model 9 Natural Resource
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace L.wdi_natrr if year>1988 & outcome!=.,vce(robust)
vif, uncentered


//Model 10 Labor Force Participation
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace L.wdi_lf if year>1988 & outcome!=.,vce(robust)
vif, uncentered


//Model 11 - All Economic Variables
xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits L.wdi_offexrate L.wdi_natrr L.wdi_lf govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace if year>1988 & outcome!=.,vce(robust)
vif, uncentered



//Model 12 uses CPA as a binary 
xtabond lnfdi_inward_mil_unctad_      L.inpam L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade  ln_wardur L.wdi_pop_mil L.cum_bits L.wdi_offexrate L.wdi_natrr L.wdi_lf govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace if year>1988 & outcome!=.,vce(robust)
vif, uncentered

// A6 Replicate Table 3 Robust SE

xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.coldcase L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(robust)
vif, uncentered


xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.coldcase L.outcome_GovtVic  L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(robust)
vif, uncentered


xtabond lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.coldcase L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(robust)
vif, uncentered


xtabond lnfdi_inward_mil_unctad_    L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.coldcase L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(robust)
vif, uncentered





//////////////
///Further Robustness Test with Robust Standard Error
//data upto ten years

//A7
//1
xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic   if year>1988 & outcome!=. & cum_peace<6, vce(robust)

//level of inflow
//2
xtabond fdi_inward_mil_usdcurrex_unctad L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic   if year>1988 & outcome!=., vce(robust)

  //&replicate model 3 that introduces the executive constraints measure
  //Replicate the same model that accounts for democracy binary
//3
xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.democracy  if year>1988 & outcome!=., vce(robust)
//Replicate the same model that accounts for property rights
//4
xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.quartile1  if year>1988 & outcome!=., vce(robust)
//Replicate Model 6 with the GDP per capita variable by dropping the size of poulation 
//5
xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.ln_gdppercapita L.wdi_trade L.ex_const  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total  if year>1988 & outcome!=., vce(robust)


//Also replicate Model 3 excluding excluding UK, Spain, India, and China
 //6
 xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.ex_const  if year>1988 & outcome!=. & ccode!=200 &ccode!=230 & ccode!=710 &ccode!=750  , vce(robust)

 xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.ex_const  if year>1988 & outcome!=. & ccode!=200 & ccode!=710  , vce(robust)

//Replicate Model 4 with interaction between gov victory and regime durability
//7
xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_const  L.p_durable govonlyv413m gov_v_durablepolity if year>1988 & outcome!=.  , vce(robust)


//Replicate Model 3 with the original scale for xconst
 //8
 xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.p_xconst if year>1988 & outcome!=. & p_xconst>0   , vce(robust)


//Bivariate Analysis of efvce(robust)ct of CPA on FDI
 //9
 xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate if year>1988 & outcome!=.  , vce(robust)

//Include development assistance
//10
xtabond lnfdi_inward_mil_unctad_  L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L. total_off_dev_assisnet if year>1988 & outcome!=.  , vce(robust)

 
 
//A8: Changing the Revce(robust)rence Category
 xtabond lnfdi_inward_mil_unctad_ L.agg_imp_rate  L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=., vce(robust)
 xtabond lnfdi_inward_mil_unctad_ L.nonCPA_PA  L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(robust)
 xtabond lnfdi_inward_mil_unctad_ L.outcome_RebelVic  L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(robust)
 xtabond lnfdi_inward_mil_unctad_ L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(robust)
 xtabond lnfdi_inward_mil_unctad_ L.coldcase L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. , vce(robust)


///////////REPLICATES MODELS IN TABLE 1 for international verification additional testing//////////////
//A9
xtabond lnfdi_inward_mil_unctad_   L.verificationIMP L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic   if year>1988 & outcome!=.,vce(robust)
vif, uncentered

//Model 2
xtabond lnfdi_inward_mil_unctad_    L.verificationIMP L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m if year>1988 & outcome!=.,vce(robust)
vif, uncentered

//Model 3
xtabond lnfdi_inward_mil_unctad_   L.verificationIMP L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.ex_con  if year>1988 & outcome!=.,vce(robust)
vif, uncentered

//Model 4
xtabond lnfdi_inward_mil_unctad_   L.verificationIMP L.inpam L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con ln_total_dead L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. ,vce(robust)
vif, uncentered

//A10 - replicate table 1 with fixed effect robust standard errors

//Model 1
xtreg lnfdi_inward_mil_unctad_ L.lnfdi_inward_mil_unctad_  L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic   if year>1988 & outcome!=., fe cluster(ccode)

//Model 2
xtreg lnfdi_inward_mil_unctad_  L.lnfdi_inward_mil_unctad_   L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m if year>1988 & outcome!=., fe cluster(ccode)

//Model 3
xtreg lnfdi_inward_mil_unctad_  L.lnfdi_inward_mil_unctad_   L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_trade ln_total_dead ln_wardur govonlyv413m L.ex_con  if year>1988 & outcome!=., fe cluster(ccode)

//Model 4
xtreg  lnfdi_inward_mil_unctad_ L.lnfdi_inward_mil_unctad_    L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con  L.p_durable govonlyv413m  ln_total_dead ln_wardur cum_peace_year if year>1988 & outcome!=.,fe cluster(ccode)

//Model 5
xtreg lnfdi_inward_mil_unctad_  L.lnfdi_inward_mil_unctad_   L.agg_imp_rate L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con ln_total_dead L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. ,fe cluster(ccode)

//Model 6
xtreg lnfdi_inward_mil_unctad_  L.lnfdi_inward_mil_unctad_   L.inpam L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic L.wdi_gdpgr L.wdi_pop L.wdi_trade L.ex_con ln_total_dead L.p_durable govonlyv413m  cum_peace_year L.lnpkoave_total ln_wardur if year>1988 & outcome!=. ,fe cluster(ccode)




//Figure 1
graph dot lnfdi_inward_mil_unctad_ [aweight = lnfdi_inward_mil_unctad_] if mj_conflictid!=. & cum_peace_year ==5 & ccode!=620, over(cname, sort(1)) ytitle ("FDI Inflows(Log)")
 
//Correlation Tests
pwcorr lnfdi_inward_mil_unctad_  L.lnfdi_inward_mil_unctad_ L.agg_imp_rate L.inpam L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace L.wdi_natrr ln_total_dead  L.wdi_offexrate if year>1988 & outcome!=.

//Summary Stat
sum lnfdi_inward_mil_unctad_  L.lnfdi_inward_mil_unctad_ L.agg_imp_rate L.inpam L.nonCPA_PA L.outcome_RebelVic L.outcome_GovtVic  L.wdi_gdpgr L.wdi_trade L.wdi_pop_mil ln_wardur L.cum_bits govonlyv413m L.ex_con L.p_durable L.lnpkoave_total cum_peace L.wdi_natrr ln_total_dead  L.wdi_offexrate if year>1988 & outcome!=.

log close
